let iSession = {
    set(key,value){
        if(typeof value == "object"){
            value = JSON.stringify(value);
        }
        sessionStorage.setItem(key,value);
    },
    get(key){
        let value = sessionStorage.getItem(key);
        try{
            return JSON.parse(value);
        }catch(e){
            return value;
        }
    },
    remove(key){
        sessionStorage.removeItem(key);
    },
    clear(){
        sessionStorage.clear();
    }
};

let iLocal = {
    set(key,value){
        if(typeof value == "object"){
            value = JSON.stringify(value);
        }
        localStorage.setItem(key,value);
    },
    get(key){
        let value = localStorage.getItem(key);
        try{
            return JSON.parse(value);
        }catch(e){
            return value;
        }
    },
    remove(key){
        localStorage.removeItem(key);
    },
    clear(){
        localStorage.clear();
    }
};

export {iSession,iLocal};
